home *** CD-ROM | disk | FTP | other *** search
/ Champak 26 (Anniversary Edition) / Volume 26 [Anniversary Edition] - JOGO DISK .iso / DEPOSITO / REmovido / Esportes / LightningBreak.swf / scripts / frame_1 / DoAction_2.as next >
Text File  |  2006-06-13  |  1KB  |  54 lines

  1. _global.v2d = new Object();
  2. _global.v2d.math = new Object();
  3. _global.v2d.math.p2pDistance = function(x1, y1, x2, y2)
  4. {
  5.    var tx = x2 - x1;
  6.    var ty = y2 - y1;
  7.    return Math.sqrt(tx * tx + ty * ty);
  8. };
  9. _global.v2d.math.squareHit = function(x1, y1, x2, y2, s)
  10. {
  11.    return Math.abs(x1 - x2) <= s && Math.abs(y1 - y2) <= s;
  12. };
  13. _global.v2d.math.rectHit = function(x1, y1, x2, y2, sx, sy)
  14. {
  15.    return Math.abs(x1 - x2) <= sx && Math.abs(y1 - y2) <= sy;
  16. };
  17. _global.v2d.math.withinRect = function(x1, y1, x2, y2, x3, y3)
  18. {
  19.    return _global.v2d.math.numBetween(x1,x3,x2) == true && _global.v2d.math.numBetween(y1,y3,y2) == true;
  20. };
  21. _global.v2d.math.r2vertSgnAngle = function(x1, y1, x2, y2)
  22. {
  23.    var rad = Math.asin((x2 - x1) / _global.v2d.math.p2pDistance(x1,y1,x2,y2));
  24.    return y2 > y1 ? 3.141592653589793 - rad : rad;
  25. };
  26. _global.v2d.math.r2vertCwAngle = function(x1, y1, x2, y2)
  27. {
  28.    var temp = Math.asin((x2 - x1) / _global.v2d.math.p2pDistance(x1,y1,x2,y2));
  29.    if(temp < 0)
  30.    {
  31.       temp += 6.283185307179586;
  32.    }
  33.    return temp;
  34. };
  35. _global.v2d.math.numBetween = function(a, b, c)
  36. {
  37.    if(a == c)
  38.    {
  39.       return b == a;
  40.    }
  41.    if(c > a)
  42.    {
  43.       return b > a && b < c;
  44.    }
  45.    return b > c && b < a;
  46. };
  47. _global.v2d.math.unify = function(v)
  48. {
  49.    var l = Math.sqrt(v.x * v.x + v.y * v.y);
  50.    v.x /= l;
  51.    v.y /= l;
  52.    return v;
  53. };
  54.